import { listOrgUser } from '@/api/customer/orgUser'

const state = {
  steps_active: 2,
  request_data: {},
  user_list: {}
}

const mutations = {
  SET_STEPS: (state, data) => {
    state.steps_active = data
  },
  STEPS_ADD: (state) => {
    state.steps_active += 1
  },
  REQ_FORM: (state, data) => {
    state.request_data = { ...state.request_data, ...data }
  },
  SET_USER: (state, data) => {
    state.user_list = data
  }
}

const actions = {
  listOrgUser({ commit }, departmentId) {
    return new Promise((resolve, reject) => {
      listOrgUser({ pageIndex: 1, pageSize: 99999999, departmentId }).then((res) => {
        commit('SET_USER', res.data)
        resolve(resolve)
      }).catch(error => {
        reject(error)
      })
    })
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}

